package GUI;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import Fileutil.fileInput;


public class GUISwing {
	JTextField tx;
	JTextArea ta;
	JButton cx;
	JButton bc;
	JLabel bq;
	
	public void showMyGUI() {
		cx=new JButton("search");
		bc=new JButton("save");
		tx=new JTextField(20);
		ta=new JTextArea(20,20);
		bq=new JLabel("please input");
		
		JPanel p=new JPanel();
		p.add(bq);
		p.add(tx);
		p.add(cx);
		p.add(bc);
		
		JFrame f=new JFrame("Employee");
		f.add(p,BorderLayout.NORTH);
		f.add(ta,BorderLayout.CENTER);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		f.setVisible(true);
		f.setSize(500,500);
		f.setLocation(300,300);
		
		cx.addActionListener(new ActionListener() {
			//当鼠标单击按钮时处理的内容
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			fileInput f=new fileInput();
			if(tx.getText().trim().length()==0) {
				
				ta.setText(f.getDateFromFile());
			}
			else {
				String s=tx.getText().trim();
				f.getDateFromFile();
				ta.setText(f.aaa(s));
			}
				
		}
		
	});//按钮监听器，鼠标点击
	
		bc.addActionListener(new ActionListener() {
			//当鼠标单击按钮时处理的内容
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			String st=tx.getText();
			
			fileInput f=new fileInput();
			f.getDateFromFile();
			f.wr(f.aaa(st), st);
			
		}
		
	});//按钮监听器，鼠标点击
		
		
	}
	

}
